package com.gears_software.bbnetwork.adapters;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.gears_software.bbnetwork.datas.models.ViwepagerModel;
import com.gears_software.bbnetwork.views.ViewpagerItemView;
import com.gears_software.bbnetwork.views.ViewpagerItemView_;
import com.gears_software.common.ui.scrollviewpager.RecyclingPagerAdapter;

public class ViewpagerAdapter extends RecyclingPagerAdapter {
	
	List<ViwepagerModel> list;
	Context context;

	public ViewpagerAdapter(List<ViwepagerModel> list, Context context) {
		super();
		this.list = list;
		this.context = context;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup container) {
		ViewpagerItemView view = null;
		if(convertView==null){
			view = ViewpagerItemView_.build(context);
		}else{
			view = (ViewpagerItemView) convertView;
		}
		view.bind(list.get(position));
		return view;
	}

	@Override
	public int getCount() {
		if(list!=null){
			return list.size();
		}else{
			return 0;
		}
	}

}
